package tom.jiafei;
import java.sql.*;
public class Update{
	public boolean update(String updateCondition) {

		boolean  x=false;
		Connection con;
	    Statement sql;
	    try{
	    	Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
	    	}
	    catch(Exception e){}
   
    try{
		String uri = "jdbc:sqlserver://127.0.0.1:1433;DatabaseName=book_store";
		String user = "sa";
		String password = "sa";
		con=DriverManager.getConnection(uri,user,password);
		sql=con.createStatement();
		int m=sql.executeUpdate(updateCondition);
		if(m!=0){
			x=true;			
		}
		con.close();
	}
	catch(SQLException e1){x=false;}
    return x;
	}
	public boolean update_(String table,String propety,String value,String userid) {
		try{
			byte a[]=value.getBytes("ISO-8859-1");
            value=new String(a);}
        catch(Exception e){
        }
        String updateCondition="update "+table+" set "+propety+"='"+value+"' where userid='"+userid+"'";
		boolean  x=false;
		Connection con;
	    Statement sql;
	    try{
	    	Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
	    	}
	    catch(Exception e){}
   
    try{
		String uri = "jdbc:sqlserver://127.0.0.1:1433;DatabaseName=book_store";
		String user = "sa";
		String password = "sa";
		con=DriverManager.getConnection(uri,user,password);
		sql=con.createStatement();
		int m=sql.executeUpdate(updateCondition);
		if(m!=0){
			x=true;			
		}
		con.close();
	}
	catch(SQLException e1){x=false;}
    return x;
	}
}